﻿using System;

namespace FeedbackNetwork.network.loss
{
    class MSE : Loss
    {
        public override FloatTensor[] Delta(FloatTensor predict, FloatTensor real)
        {
            return new FloatTensor[] { real.Sub(predict), real.Sub(predict) };
        }

        /// <summary>
        /// 每一列求Loss
        /// </summary>
        /// <param name="predict"></param>
        /// <param name="real"></param>
        /// <returns></returns>
        public override FloatTensor GetLoss(FloatTensor predict, FloatTensor real)
        {
            FloatTensor temp = predict.Sub(real);
            temp = temp.Mul(temp);//差值的平方
            temp = temp.RowMean();//行求和，每一组数据算成一个Loss值
            return temp;

        }
    }
}
